<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
				<style>
					#AjaxBox {text-align: left; padding: 10px; background: #fff;}
					#AjaxBox #Title {
						padding: 5px 0 5px 10px;
						background: #40aa53;
						color: #fff;
						font-size: 10pt;
						font-weight: bold;
						margin-bottom: 10px;
					}
					#AjaxBox #Title a {color: #ff0; margin: 0 3px;}
					
					#AjaxBox form {}
					#AjaxBox form .SUBMIT {font-weight: bold;}
					#AjaxBox form input {padding: 1px 2px;}
					#AjaxBox form textarea {background: #ffd; border: 1px solid #ccc; padding: 2px;}
					#AjaxBox form tr.submit td {padding-top: 20px;}
					
					#AjaxBox form table {}
					#AjaxBox form table tr th {text-align: right;}
					#AjaxBox form table tr td {padding: 0 0 5px 0;}
					#AjaxBox form table tr td.heading {font-weight: bold; padding: 0;}
					#AjaxBox form table tr td input {padding: 2px;}
					#AjaxBox form table tr td textarea {font-size: 10pt; padding: 2px;}
					#AjaxBox form table tr.submit td input {font-size: 10pt; padding: 2px 5px;}
					
					#AjaxBox form from h2 {font-size: 12pt; border-bottom: 1px solid #ccc; margin:0; padding: 10px 0 10px 20px;}
					#AjaxBox form from h2 a {margin: 0 5px;}
				</style>
				<div id = "AjaxBox" style = "display: none;">
					<h2 id = "Title">发送留言给 <u></u></h2>
					<div id = "Content">
						<div id = "s_error_msg" class = "error_msg" style = "display: none;"></div>
						<div id = "s_success_msg" class = "ok_msg" style = "display: none;"></div>
						<form id = "frm_sendmsg" action = "/action/msg/send" method = "post">
							<input type = "hidden" id = "receiverId" name = "receiver" value = "" />
							<table>
								<tr><td class = "heading">留言内容:</td></tr>
								<tr>
									<td>
										<textarea id = "ta_msg_content" name = "content" placeholder = "最多250个字" 
										class = "form-contorl" style = "width:400px;height:120px;padding:2px; overflow: auto; background:#fff;"></textarea>
									</td>
								</tr>
								<tr class = "submit">
									<td>
										<input type = "button" value = "发送" class = "btn btn-primary" style = "width:82px; height: 34px;" id = "btn_sm_send" onclick = "PostMsg()"></input>
									</td>
								</tr>
							</table>
						</form>
					</div>
				</div>
				<script>
					function sendmsg(otherId, otherName) {
						$('#AjaxBox #Title u').html(otherName);
						$('#receiverId').val(otherId);
						$.fancybox({
							padding: 0,
							type: 'inline',
							href: '#AjaxBox',
							afterClose: function() {
								document.getElementById('s_error_msg').setAttribute('style', 'display:none');
								document.getElementById('s_success_msg').setAttribute('style', 'display:none');
								$('#AjaxBox #Title u').html('');
								$('#receiverId').val('');
								$('#ta_msg_content').val('');
								return true;
							},
							helpers: {
								overlay: {
									closeClick: false,
									css: {'background':'rgba(83,83,83,0.6)'},
								},
							},
						});
					}
					function PostMsg() {
						$('#s_error_msg').hide();
						$('#s_success_msg').hide();
						if ($('#ta_msg_content').val().length == 0) {
							$('#s_error_msg').html('留言不能为空');
							$('#s_error_msg').show();
							return false;
						}
						if ($('#ta_msg_content').val().length > 250) {
							$('#s_error_msg').html('留言字数超过了250个');
							$('#s_error_msg').show();
							return false;
						}
						if (!visitorStatus.login) {
							$('#s_error_msg').html("请先<a href = '${initParam.webRootUrl}account/login.jsp?goto_page=" + location.href + "'>登录</a>");
							$('#s_error_msg').show();
							return false;
						}
						$('#frm_sendmsg').ajaxSubmit({
							dataType: 'json',
							success: function(result) {
								if (result.status == 1) {
									$('#ta_msg_content').val('');
									$('#s_success_msg').html('留言成功');
									$('#s_success_msg').show();
								}
							}
						});
					}
				</script>